package cn.zcy.log;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

//@Component
//@Aspect
//@Order
public class LogUntils {

    @Before(value = "execution(public * cn.zcy.service.impl.*.*(..))")
    public void before(JoinPoint joinPoint) {
        String name = joinPoint.getSignature().getName();
        System.out.println("方法的名称 = " + name);
        Object[] args = joinPoint.getArgs();
        for (Object arg : args) {
            System.out.println("参数 = " + arg);
        }
    }

    @After(value = "execution(public * cn.zcy.service.impl.*.*(..))")//对切入点表达式的引用
    public void after() {
        System.out.println("后置增强");
    }

    @AfterReturning(value = "execution(public * cn.zcy.service.impl.*.*(..))", returning = "result")//对切入点表达式的引用 ,returning = "result"

    public void afterReturning(JoinPoint joinPoint,Object result ) {//,Object result

        System.out.println("后置返回="+result);
    }

    @AfterThrowing(value = "execution(public * cn.zcy.service.impl.*.*(..))",throwing = "e")//对切入点表达式的引用
    public void afterThrowing(JoinPoint joinPoint,Throwable e) {
        System.out.println("异常="+e);
    }


}
